package grad.nxu.recruitsystem.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import grad.nxu.recruitsystem.domain.Hr;
import grad.nxu.recruitsystem.dto.User;
import grad.nxu.recruitsystem.mapper.HrMapper;
import grad.nxu.recruitsystem.service.HrService;
import grad.nxu.recruitsystem.vo.BiographicalNotesVO;
import grad.nxu.recruitsystem.vo.JobApplicationVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author HAPPY
 * @description 针对表【hr】的数据库操作Service实现
 * @createDate 2023-03-09 22:59:06
 */
@Service
public class HrServiceImpl extends ServiceImpl<HrMapper, Hr>
        implements HrService {
    @Autowired
    HrMapper hrMapper;

    @Override
    public User login(User hr) {
        return hrMapper.login(hr);
    }

    @Override
    public int modifyPassword(String email, String password) {
        if (hrMapper.modifyPassword(email, password)) {
            return 1;
        } else {
            return 0;
        }
    }

    @Override
    public List<JobApplicationVO> getBiographicalNotesByPage(Integer companyId, Integer pageSize, Integer pageNumber) {
        Integer offset = pageSize * (pageNumber - 1);
        return hrMapper.selectAll(companyId,pageSize,offset);
    }

    @Override
    public List<JobApplicationVO> getBiographicalNotesByAge(Integer age,Integer companyId, Integer pageSize, Integer pageNumber) {
        Integer offset = pageSize * (pageNumber - 1);
        return hrMapper.selectAllByAge(age,companyId,pageSize,offset);
    }

    @Override
    public List<JobApplicationVO> getBiographicalNotesByGender(String gender, Integer companyId, Integer pageSize, Integer pageNumber) {
        Integer offset = pageSize * (pageNumber - 1);
        return hrMapper.selectAllByGender(gender,companyId,pageSize,offset);
    }

    @Override
    public BiographicalNotesVO getOneBiographicalNote(Integer biographicalId) {
        return hrMapper.selectOneByBiographicalNoteId(biographicalId);
    }

}




